package nbcondominios

import java.util.Date;

class Periodos {
    
    static hasMany = [cuotas:Cuotas]
    Integer anno = Integer.parseInt(new Date().getAt(Calendar.YEAR).toString())
    Integer mes = Integer.parseInt(new Date().getAt(Calendar.MONTH).toString())
    String periodo = anno.toString()+"-"+mes.toString().padLeft(2, '0')
    String descripcion = "Cuota - Año: 9999  /  Mes: 99 ....."
    Double nuvalor = 0.00
    Date dateCreated
    Date lastUpdated
    def beforeInsert = {
        
    }
    def afterInsert = {
        
    }
    def beforeUpdate = {
        
    }
    
    def beforeDelete = {
        // your code goes here
    }
    def onLoad = {
        // your code goes here
    }
    
    String toString() {
		"$periodo"
    }
        
    static constraints = {
        anno(min:2000,max:3000)
        mes(min:1,max:12)
        periodo(blank:false, unique:true)
        descripcion(blank:false,maxSize:500)
        nuvalor(validator:{return(it> 0.00)})
        dateCreated()
        lastUpdated()
        cuotas()
    }
}